package com.edu.juc.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) {
        new Thread(() -> System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName()), "Runnable");

        FutureTask<Integer> futureTask = new FutureTask<>(() -> {
            System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
            return 1;
        });

        new Thread(futureTask, "FutureTask1").start();

        try {
            System.out.println(futureTask.get());
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        // FutureTask原理 未来任务

    }
}
